﻿using Furion.EventBus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Furion.CMS.Core.EventSource
{
    /// <summary>
    /// 缓存操作类型
    /// </summary>
    public enum CacheOperationType
    {
        /// <summary>
        /// 添加
        /// </summary>
        Add,
        /// <summary>
        /// 移除
        /// </summary>
        Remove,
        /// <summary>
        /// 清空
        /// </summary>
        Clear
    }

    /// <summary>
    /// 缓存事件基类
    /// </summary>

    public abstract class CacheEvent : IEventSource
    {
        protected CacheEvent(string eventId)
        {
            EventId = eventId;
            CreatedTime = DateTime.UtcNow;
        }

        /// <summary>
        /// 操作类型
        /// </summary>
        public CacheOperationType OperationType { get; protected set; }

        /// <summary>
        /// 事件ID
        /// </summary>
        public string EventId { get; }
        /// <summary>
        /// 事件承载（携带）数据
        /// </summary>
        public object Payload { get; protected set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedTime { get; }
        /// <summary>
        /// 取消令牌
        /// </summary>
        public CancellationToken CancellationToken { get; }
    }
}
